﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using BEX.WebUI.Entities;

namespace BEX.WebUI.Controllers
{
    public class IncrementRuleController : Controller
    {
        private BTC_SMSEntities db = new BTC_SMSEntities();

        //
        // GET: /IncrementRule/

        public ActionResult Index()
        {
            var alert_rule_increment = db.ALERT_RULE_INCREMENT.Include(a => a.CURRENCY).Include(a => a.CURRENCY1).Include(a => a.EXCHANGE);
            return View(alert_rule_increment.ToList());
        }

        //
        // GET: /IncrementRule/Details/5

        public ActionResult Details(int id = 0)
        {
            ALERT_RULE_INCREMENT alert_rule_increment = db.ALERT_RULE_INCREMENT.Find(id);
            if (alert_rule_increment == null)
            {
                return HttpNotFound();
            }
            return View(alert_rule_increment);
        }

        //
        // GET: /IncrementRule/Create

        public ActionResult Create()
        {
            ViewBag.BASE_CURRENCY_ID = new SelectList(db.CURRENCies, "CURRENCY_ID", "CURRENCY1");
            ViewBag.COUNTER_CURRENCY_ID = new SelectList(db.CURRENCies, "CURRENCY_ID", "CURRENCY1");
            ViewBag.EXCHANGE_ID = new SelectList(db.EXCHANGEs, "ID", "NAME");
            return View();
        }

        //
        // POST: /IncrementRule/Create

        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Create(ALERT_RULE_INCREMENT alert_rule_increment)
        {
            if (ModelState.IsValid)
            {
                db.ALERT_RULE_INCREMENT.Add(alert_rule_increment);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.BASE_CURRENCY_ID = new SelectList(db.CURRENCies, "CURRENCY_ID", "CURRENCY1", alert_rule_increment.BASE_CURRENCY_ID);
            ViewBag.COUNTER_CURRENCY_ID = new SelectList(db.CURRENCies, "CURRENCY_ID", "CURRENCY1", alert_rule_increment.COUNTER_CURRENCY_ID);
            ViewBag.EXCHANGE_ID = new SelectList(db.EXCHANGEs, "ID", "NAME", alert_rule_increment.EXCHANGE_ID);
            return View(alert_rule_increment);
        }

        //
        // GET: /IncrementRule/Edit/5

        public ActionResult Edit(int id = 0)
        {
            ALERT_RULE_INCREMENT alert_rule_increment = db.ALERT_RULE_INCREMENT.Find(id);
            if (alert_rule_increment == null)
            {
                return HttpNotFound();
            }
            ViewBag.BASE_CURRENCY_ID = new SelectList(db.CURRENCies, "CURRENCY_ID", "CURRENCY1", alert_rule_increment.BASE_CURRENCY_ID);
            ViewBag.COUNTER_CURRENCY_ID = new SelectList(db.CURRENCies, "CURRENCY_ID", "CURRENCY1", alert_rule_increment.COUNTER_CURRENCY_ID);
            ViewBag.EXCHANGE_ID = new SelectList(db.EXCHANGEs, "ID", "NAME", alert_rule_increment.EXCHANGE_ID);
            return View(alert_rule_increment);
        }

        //
        // POST: /IncrementRule/Edit/5

        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Edit(ALERT_RULE_INCREMENT alert_rule_increment)
        {
            if (ModelState.IsValid)
            {
                db.Entry(alert_rule_increment).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            ViewBag.BASE_CURRENCY_ID = new SelectList(db.CURRENCies, "CURRENCY_ID", "CURRENCY1", alert_rule_increment.BASE_CURRENCY_ID);
            ViewBag.COUNTER_CURRENCY_ID = new SelectList(db.CURRENCies, "CURRENCY_ID", "CURRENCY1", alert_rule_increment.COUNTER_CURRENCY_ID);
            ViewBag.EXCHANGE_ID = new SelectList(db.EXCHANGEs, "ID", "NAME", alert_rule_increment.EXCHANGE_ID);
            return View(alert_rule_increment);
        }

        //
        // GET: /IncrementRule/Delete/5

        public ActionResult Delete(int id = 0)
        {
            ALERT_RULE_INCREMENT alert_rule_increment = db.ALERT_RULE_INCREMENT.Find(id);
            if (alert_rule_increment == null)
            {
                return HttpNotFound();
            }
            return View(alert_rule_increment);
        }

        //
        // POST: /IncrementRule/Delete/5

        [HttpPost, ActionName("Delete")]
        [ValidateAntiForgeryToken]
        public ActionResult DeleteConfirmed(int id)
        {
            ALERT_RULE_INCREMENT alert_rule_increment = db.ALERT_RULE_INCREMENT.Find(id);
            db.ALERT_RULE_INCREMENT.Remove(alert_rule_increment);
            db.SaveChanges();
            return RedirectToAction("Index");
        }

        protected override void Dispose(bool disposing)
        {
            db.Dispose();
            base.Dispose(disposing);
        }
    }
}